﻿@using bpms.Enums
@model RegisterViewModel
@{
    ViewData["Title"] = "用户注册";
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewData["Title"]</title>
    <style>

        /* 完全匹配图片中的样式 */
        html, body {
            height: 100%;
            margin: 0;
            font-family: 'Microsoft YaHei', sans-serif;
            background: #f0f2f5;
        }

        /* 新增：外层滚动容器 */
        .scroll-container {
            height: 100vh;
            overflow-y: auto;
            padding-top: 20px; /* 保持与图片相同的顶部间距 */
            display: flex;
            flex-direction: column;
        }

        /* 完全复制图片中的注册框 */
        .register-box {
            width: 500px;
            margin: 0 auto 20px; /* 保持底部间距 */
            background: white;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            border-radius: 8px;
            overflow: hidden;
        }

        /* 标题栏（1:1还原图片蓝绿渐变） */
        .register-header {
            background: linear-gradient(90deg, #3498db, #2ecc71);
            color: white;
            padding: 15px;
            text-align: center;
            font-size: 18px;
            position: sticky; /* 新增：滚动时固定 */
            top: 0;
            z-index: 10;
        }

        /* 表单内容区（保持图片内边距） */
        .register-body {
            padding: 25px;
        }

        /* 选项卡（与登录页相同样式） */
        .role-tabs {
            display: flex;
            margin-bottom: 25px;
            border-radius: 4px;
            overflow: hidden;
            border: 1px solid #e0e0e0;
        }

        .role-tab {
            flex: 1;
            padding: 10px;
            text-align: center;
            cursor: pointer;
            background: #f8f9fa;
        }

            .role-tab.active {
                background: #3498db;
                color: white;
            }

        /* 关键修改：双列表单布局 */
        .form-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 20px 15px; /* 行间距20px，列间距15px */
        }

        .form-group {
            margin-bottom: 0; /* 去除单独间距 */
        }

        .form-label {
            display: block;
            margin-bottom: 8px;
            font-size: 14px;
            color: #333;
        }

        .form-input {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 14px;
            height: 40px;
            box-sizing: border-box;
        }

        /* 全宽字段（地址和按钮） */
        .full-width {
            grid-column: span 2;
        }

        /* 登录按钮（与登录页相同样式） */
        .register-btn {
            width: 100%;
            padding: 12px;
            background: linear-gradient(to right, #3498db, #2ecc71);
            border: none;
            color: white;
            border-radius: 4px;
            font-size: 16px;
            cursor: pointer;
            margin-top: 10px;
        }

        /* 登录链接（与登录页相同样式） */
        .login-link {
            text-align: center;
            margin-top: 15px;
            font-size: 14px;
            color: #666;
        }

            .login-link a {
                color: #3498db;
                text-decoration: none;
                margin-left: 5px;
            }

        .text-danger {
            font-size: 12px;
            color: #e74c3c;
            margin-top: 5px;
            display: block;
        }
    </style>
</head>
<body>
    <div class="register-box">
        <div class="register-header">用户注册</div>
        <div class="register-body">
            <div class="role-tabs">
                <div class="role-tab active" data-role="0">管理员</div>
                <div class="role-tab" data-role="1">顾客</div>
            </div>

            <form asp-action="Register" method="post">
                <input type="hidden" asp-for="UserType" id="userType" />

                <!-- 双列网格布局 -->
                <div class="form-grid">
                    <!-- 第一行 -->
                    <div class="form-group">
                        <label class="form-label">登录名</label>
                        <input asp-for="LoginName" class="form-input" placeholder="请输入用户名">
                        <span asp-validation-for="LoginName" class="text-danger"></span>
                    </div>

                    <div class="form-group">
                        <label class="form-label">姓名</label>
                        <input asp-for="Name" class="form-input" placeholder="请输入真实姓名">
                        <span asp-validation-for="Name" class="text-danger"></span>
                    </div>


                    <!-- 第二行 -->
                    <div class="form-group">
                        <label class="form-label">密码</label>
                        <input asp-for="Password" type="password" class="form-input" placeholder="请输入密码">
                        <span asp-validation-for="Password" class="text-danger"></span>
                    </div>

                    <div class="form-group">
                        <label class="form-label">确认密码</label>
                        <input asp-for="ConfirmPassword" type="password" class="form-input" placeholder="请再次输入密码">
                        <span asp-validation-for="ConfirmPassword" class="text-danger"></span>
                    </div>

                    <!-- 第三行 -->
                    <div class="form-group">
                        <label class="form-label">电话</label>
                        <input asp-for="Phone" class="form-input" placeholder="请输入联系电话">
                        <span asp-validation-for="Phone" class="text-danger"></span>
                    </div>

                    <!-- 顾客专属字段（自动全宽） -->
                    <div class="form-group customer-only full-width" style="display:@(Model.UserType == UserType.Customer ? "block" : "none")">
                        <label class="form-label">地址</label>
                        <input asp-for="Address" class="form-input" placeholder="请输入详细地址">
                        <span asp-validation-for="Address" class="text-danger"></span>
                    </div>
                </div>

                <button type="submit" class="register-btn full-width">注册</button>
            </form>

            <div class="login-link">
                已有账号？<a href="@Url.Action("Login")">立即登录</a>
            </div>
        </div>
    </div>

    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script>
               $(function () {
            // 角色切换功能
            $('.role-tab').click(function () {
                $('.role-tab').removeClass('active');
                $(this).addClass('active');
                $('#userType').val($(this).data('role'));

                var userType = $('#userType').val();
                if (userType == 0) {
                    $('.customer-only').hide();
                    $('.customer-only input').prop('disabled', true); // 禁用
                } else {
                    $('.customer-only').show();
                    $('.customer-only input').prop('disabled', false); // 启用
                }
            });

            // 页面加载时，根据 #userType 设置默认选中项
            var userType = $('#userType').val();
            $('.role-tab').removeClass('active');
            $('.role-tab[data-role="' + userType + '"]').addClass('active');
            if (userType == 0) {
                $('.customer-only').hide();
                $('.customer-only input').prop('disabled', true);
            } else {
                $('.customer-only').show();
                $('.customer-only input').prop('disabled', false);
            }

        });

    </script>
</body>
</html>
